package cn.lili.controller.order;


import cn.lili.common.aop.annotation.PreventDuplicateSubmissions;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.order.order.entity.dos.RankingGrowAwardConfig;
import cn.lili.modules.order.order.entity.dos.RankingGrowAwardStatus;
import cn.lili.modules.order.order.service.IRankingGrowAwardConfigService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 成长奖励奖品配置 前端控制器
 * </p>
 *
 * @author zhushiqing
 * @since 2023-12-21
 */
@AllArgsConstructor
@RestController
@RequestMapping("/order/rankingGrowAwardConfig")
public class RankingGrowAwardConfigController {

    private IRankingGrowAwardConfigService rankingGrowAwardConfigService;

    /**
     * 成长奖励: 获取当前用户佣金值，与当前活动的奖品与佣金（需返回是否领取过）,领取过需返回物流单号
     *
     * @return 成长奖励
     */
    @GetMapping("/growthReward")
    public ResultMessage<Object> growthReward() {
        return ResultUtil.data(rankingGrowAwardConfigService.growthReward());
    }

    /**
     * 领取奖励
     *
     * @param rankingGrowAwardStatus 奖品id,收货信息
     */
    @PostMapping("/receiveAReward")
    public ResultMessage<Object> receiveAReward(@RequestBody RankingGrowAwardStatus rankingGrowAwardStatus) {
        return rankingGrowAwardConfigService.receiveAReward(rankingGrowAwardStatus);
    }

    /**
     * 查看物流信息
     * @param claimableId 领取记录id
     * @return 收货信息 + 物流信息
     */
    @GetMapping("/viewLogistic")
    public ResultMessage<Object> viewLogistic(@RequestParam String claimableId) {
        return rankingGrowAwardConfigService.viewLogistic(claimableId);
    }


    @PostMapping("/addRankingGrowAwardConfig")
    @ApiOperation("配置成长奖励-添加-奖励奖品")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> addRankingGrowAwardConfig(@RequestBody RankingGrowAwardConfig config) {
        return rankingGrowAwardConfigService.addRankingGrowAwardConfig(config);
    }


    @PostMapping("/editRankingGrowAwardConfig")
    @ApiOperation("配置成长奖励-编辑-奖励奖品")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> editRankingGrowAwardConfig(@RequestBody RankingGrowAwardConfig config) {
        return rankingGrowAwardConfigService.editRankingGrowAwardConfig(config);
    }


    @PostMapping("/deleteRankingGrowAwardConfig/{id}")
    @ApiOperation("删除成长奖励配置")
    @PreventDuplicateSubmissions
    public ResultMessage<Object> deleteRankingGrowAwardConfig(@PathVariable String id) {
        return rankingGrowAwardConfigService.deleteRankingGrowAwardConfig(id);
    }

    @GetMapping("/getRankingGrowAwardConfigs")
    @ApiOperation("获取成长奖励奖品配置")
    public ResultMessage<List<RankingGrowAwardConfig>> getRankingGrowAwardConfigs() {
        return ResultUtil.data(rankingGrowAwardConfigService.getRankingGrowAwardConfigs());
    }

    @GetMapping("/getRankingGrowAwardConfigListKeyVal")
    @ApiOperation("获取成长奖励奖品配置->下拉条件框里展示")
    public ResultMessage<Object> getRankingGrowAwardConfigListKeyVal() {
       return rankingGrowAwardConfigService.getRankingGrowAwardConfigListKeyVal();
    }
}
